package es.cmis.utils;

import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;

import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;

public class PropertiesManager {
	
	private static PropertiesManager instancia;
	
	private Configuration globalProperties;
	private static String rutaAlProperties = "capaServiciosProperties.properties";
	
	private PropertiesManager(){
		try {
			
			globalProperties =  new PropertiesConfiguration(rutaAlProperties);
					
		} catch (ConfigurationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public static void configure(String rutaAlProperties){
		setRutaAlProperties(rutaAlProperties);
		getInstance();
	}
	
	public static PropertiesManager getInstance(){
		if(instancia == null) {
			instancia = new PropertiesManager();
		}
		return instancia;
	}
	
	public Object obtenerParametro(String clave){
		return globalProperties.getString(clave);
	}
	private static String getRutaAlProperties() {
		return rutaAlProperties;
	}

	private static void setRutaAlProperties(String ruta) {
		rutaAlProperties = ruta;
	}
}
